package com.ctrip.demo.design.adapter;

/**
 * @author xs.wu
 * @date 2021/5/19
 * 测试Adapter
 */
public class TestAdapter {

    public static void main(String[] args) {

        Wash wash = new Wash("海尔洗衣机");
        ThreeElectricOutlet outlet = wash;
        System.out.println("使用三厢插座接通电流");
        outlet.connectElectricCurrent();


        TV tv = new TV("液晶电视");
        ThreeElectricAdapter adapter = new ThreeElectricAdapter(tv);
        outlet = adapter;
        System.out.println("使两厢插座接通电流");
        outlet.connectElectricCurrent();

    }

}

class Wash implements ThreeElectricOutlet{

    private String name;

    public Wash(String name) {
        this.name = name;
    }

    @Override
    public void connectElectricCurrent() {

        turnOn();
    }

    public void turnOn() {
        System.out.println("开始洗衣服了！！");
    }
}

class TV implements TwoElectricOutlet{

    private String name;

    public TV(String name) {
        this.name = name;
    }

    @Override
    public void connectElectricCurrent() {

        turnOn();
    }

    public void turnOn() {
        System.out.println("开始播放电视了！！");
    }
}